<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/common/commonCss.jsp"/>
<jsp:include page="/common/commonJs.jsp"/>
<script src="${basePath}commonJs/jquery.ztree.all.js"></script>
<script src="${basePath}commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<script  type="text/javascript" src="${basePath }commonJs/ajaxfileupload.js"></script>
<script src="${basePath}commonJs/jquery.imageScroller.js"></script>
<title>嘉童游乐中心-供应商信息</title>
<script type="text/javascript">
 //选中的商品
//标记被选中节点
var selectNode=null;
var treeNodes=[];
var excludeId=[];//新增时保存已选择的商品
var excludeForUpdate=[];//修改时保存已选择的商品
var selectProduct=[];
var price=[];
var oldSize=0;//上一次修改的商品
var productForUdate=[];//修改商品时保存的数据
var addForUpdate=[];//修改时新增的商品
var idAndPriceAddForUpdate=[];//新增的商品价格信息forupdate 

var fileKey="${fileKey}";//文件存放路径的常量
var setting = {
	data: {
		simpleData: {
			enable: true
		}
	},
	callback:{
		onClick:zTreeonclick
	}
};
function  canCelSelUpdate(){
	$("#updateAgreement").window('close');
}
function zTreeonclick(event, treeId, treeNode) {
	selectNode = treeNode;// 每次点击赋值 
	//根据点击的商品分类查询
	var  fkPrdcateId=selectNode.id;
	$("#fkPrdcateId").val(fkPrdcateId);
	$("#pageNo").val("1");
	initParams();
};
//初始化参数
function initParams() {
	var myform = $("#productInfo");
	$("#pageNo").val("1");
	var pagebean = new PageBean(myform);
	pagebean.setTableId("showData");
	pagebean.setFootId("foot");
	pagebean.setCallback(showData);
	setPagebeanObj(pagebean); //全局化pageBean对象
	pagebean.doPage();  //执行分页
}

//展示数据
function showData(result){
	trimJsonArray(result);
	$(result).each(function(index,item){
		var html="<tr>";
		 html+="<td><input type='checkbox' value="+item.pkPrdId+" class='idFlag'  name='single'  onclick='isSelected(\"single\",\"selectAll\",\"showData\");' ></td>";
		 html+="<td>"+(index+1)+"</td>";
		 html+="<td>"+item.pkPrdId+"</td>";
		 if(item.prdName.length>7){
			 html+="<td name='cPrdName' title="+item.prdName+">"+item.prdName.substring(0,7)+"...</td>";
		 }else{
			 html+="<td name='cPrdName'>"+item.prdName+"</td>";
		 }
		 if(item.cateName.length>8){
			 html+="<td name='cCateName' title="+item.cateName+">"+item.cateName.substring(0,8)+"...</td>";
		 }else{
			 html+="<td name='cCateName'>"+item.cateName+"</td>";
		 }
		 if(item.prdSpec==""||item.prdSpec==null){
			 html+="<td name='cPrdSpec'>无</td>";
		 }else{
			 html+="<td name='cPrdSpec'>"+item.prdSpec+"</td>";
		 }
		 if(item.unitName==""||item.unitName==null){
			 html+="<td name='cUnitName'>无</td>";
			 
		 }else{
			 html+="<td name='cUnitName'>"+item.unitName+"</td>";
		 }
		 if(item.comments==null||item.comments==""){
			 html+="<td>无</td>";
		 }else{
			 if(item.comments.length>5){
				 	html+="<td title="+item.comments+">"+item.comments.substring(0,5)+"...</td>";
			 }else{
				 	html+="<td>"+item.comments+"</td>";
			 }
		 }
		 if(item.prdStatus=='1'){
			 html+="<td>正常</td>";			 
		 }else if(item.prdStatus=='2'){
			 html+="<td>停用</td>";
		 }else{
			 html+="<td>未定价</td>";
		 }
			html+="</tr>";
		 $("#showData").find("tr:eq("+index+")").after(html);
	});
}
/*得到商品分类的数据信息*/
function   getTreeData(){
			$.ajax({
					url:"${basePath}scmInvocing/productInfo/findCategoryList.shtml",
					data:{"modiBy":"supply"},
					dataType:"json",
					type:"post",
      	 			async:false,
      	 			error : function(XMLHttpRequest) {
      	 				ajaxError(XMLHttpRequest);
      	 			},
      	 			success:function(result){
      	 				var node;
      	 				$(result).each(function(id,item){
      	 					if(id==0){
	      	 					node={id:item.pkPrdcateId,pId:item.fkParPrdcateId,name:item.cateName,open:true,reserveFlag:item.reserveFlag,resverseType:item.resverseType};
      	 					}else{
	      	 					node={id:item.pkPrdcateId,pId:item.fkParPrdcateId,name:item.cateName,reserveFlag:item.reserveFlag,resverseType:item.resverseType};
      	 					}
      	 					treeNodes.push(node);
      	 				});
      	 			}
				
			});
}

function addSuplyGoods(){
	  $('#addProduct').window('open') ;
}
function closeDiv(pageName,type){
	if(type =='save'){
		alertInfo("保存成功！");
	}
	window.location.href=pageName;
}
  //保存供应商信息
  function saveSupply(){
	  	var  disabled=$("#conAddr").attr("disabled");
	  	if(disabled=="disabled"){
	  		alertWarning("不能重复此操作,如需更改请进入编辑页面!");
	  		return;
	  	}
	  	var isTrue=checkForm();
	  	if(isTrue==false){
	  		return ;
	  	}
	   	$.ajax({
	   		url:"${basePath}scmInvocing/supplier/saveSupply.shtml",
	   		data:$("#saveSupply").serialize(),
	   		dataType:"text",
	   		type:"post",
	   		error : function(XMLHttpRequest) {
	 				ajaxError(XMLHttpRequest);
	 		},
	   		success:function(result){
	   			if(result!=""){
	   			  $("#addForPkSupId").val(result);
				  $("#isFirst").val(result);
	   				$("#pkSupId").val(result);
	   				$("#fkSupId").val(result);
	   				$("#supId").val(result);
	   				$("#SupIdForm").val(result);
	   				window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
	   				//setFormStyle();
	   			/* 	$.messager.confirm('温馨提示', '保存成功,是否进行添加协议操作', function(isOk) {
	   					if (isOk==true) {
	   						addAgrement();//添加协议
	   					}else{
	   		   				window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
	   					}
	   				}); */
	   			}else{
	   				window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
	   			}
	   			
	   		}
	   		
	   	});
  }
  //保存成功之后，将页面的的表单元素禁掉
  function setFormStyle(){
	  $("#supName").attr("disabled","disabled");
	  $("#supInd").attr("disabled","disabled");
	  $("#deliverAddr").attr("disabled","disabled");
	  $("#legalRep").attr("disabled","disabled");
	  
	  $("#orgCode").attr("disabled","disabled");
	  $("#bank").attr("disabled","disabled");
	  $("#bankAccount").attr("disabled","disabled");
	  $("#conName").attr("disabled","disabled");
	  
	  $("#conMobile").attr("disabled","disabled");
	  $("#conAddr").attr("disabled","disabled");
	  $("#conFax").attr("disabled","disabled");
	  $("#conEmail").attr("disabled","disabled");
	  $("#comments").attr("disabled","disabled");
  }
  //保存并继续
  function saveSupplyAgain(){
	   				/* var pkSupId=$("#pkSupId").val();
	   			  	if(!checkIsNull(pkSupId)){
	   			  		alertInfo("该供应商已保存，不允许重复保存");
	   			  	} */
					var  disabled=$("#conAddr").attr("disabled");
				  	if(disabled=="disabled"){
				  		alertWarning("不能重复此操作,如需更改请进入编辑页面!");
				  		return;
				  	}
	   			  	var isTrue=checkForm();
	   			  	if(isTrue==false){
	   			  		return ;
	   			  	}
	   			   	$.ajax({
	   			   		url:"${basePath}scmInvocing/supplier/saveSupply.shtml",
	   			   		data:$("#saveSupply").serialize(),
	   			   		dataType:"text",
	   			   		type:"post",
	   			   		error : function(XMLHttpRequest) {
      	 					ajaxError(XMLHttpRequest);
      	 				},
	   			   		success:function(result){
	   			   			if(result!=""){
	   			   			 $("#addForPkSupId").val(result);
	   					 	 $("#isFirst").val(result);
	   			   				$("#pkSupId").val(result);
	   			   				$("#fkSupId").val(result);
	   			   				$("#supId").val(result);
	   			   				$("#SupIdForm").val(result);
	   			   				//从新进入保存页面
	   			   				window.location.href="${basePath}scmInvocing/supplier/forwardToAddSuply.shtml";
	   			   				//setFormStyle();
	   			   				/* $.messager.confirm('温馨提示', '保存成功,是否进行添加协议操作', function(isOk) {
	   			   					if (isOk==true) {
	   			   						addAgrement();//添加协议
	   			   					}else{
	   			   		   				window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
	   			   					}
	   			   				}); */
	   			   			}else{
	   			   				window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
	   			   			}
	   			   			
	   			   		}
	   			   		
	   			   	});
  }
  //跳转到主页面
  function forwardToSupplyList(){
			window.location.href="${basePath}scmInvocing/supplier/forwardToSupply.shtml";
  }
  //check form
  function checkForm(){
	  var supName=$("#supName").val();
	  if(checkIsNull(supName)){
		  alertWarning("亲,供应商名称为必填项");
		  return false;
	  }
	  var deliverAddr=$("#deliverAddr").val();
	  
	  if(checkIsNull(deliverAddr)){
		  alertWarning("亲,供货地址为必填项");
		  return false;
	  }
	  var conName=$("#conName").val();
	  if(checkIsNull(conName)){
		  alertWarning("亲,联系人为必填项");
		  return false;
	  }
	  var conAddr=$("#conAddr").val();
	  if(checkIsNull(conAddr)){
		  alertWarning("亲,联系人通讯地址为必填项");
		  return false;
	  }
	  var  conMobile=$("#conMobile").val();
	  if(checkIsNull(conMobile)){
		  alertWarning("亲,联系方式为必填项");
		  return  false;
	  }
	  return true;
  }
  function checkIsNull(val){
	  if(val==""||$.trim(val)==""){
			return true;		  
	  }
	  return false;
  }
  //添加协议
  function addAgrement(){
	 /*  var pkSupId=$("#pkSupId").val();
	  if(checkIsNull(pkSupId)){
		  alertWarning($addAgrement_worning);
		  return;
	  } */
	  //清空上一次上传记录
	  $("#fkPicFile").val("");
	  $('#addAgreement').window('open');
  }
//跳转到选择商品列表
  function forwardToSelectProduct(id){
	  	$("#selectAll").attr("checked",false);
	    $("#excludeId").val("");
	 	//获取当前列表已经选中的id值.
	  //保存操作
	  	  if(id=="update"){
	  		 oldSize=addForUpdate.length;
			  $("#excludeId").val(excludeForUpdate.join());
	  	  }else{
			  $("#excludeId").val(excludeId.join());
	  	  }
		  initParams();
		  getTreeData();
		  $("#sptree").html("");
		  $.fn.zTree.init($("#sptree"), setting, treeNodes);
		  treeNodes=[];//制空
		  $("#saveOrUpdate").val(id);
		  $("#addProduct").window('open');
  }
  //查询商品信息
  function findProductInfo(){
	  initParams();
  }
//得到选中的商品
  function getSelectProduct(){
	 //判断弹出框是为修改还是增加
	 var saveOrUpdate=$("#saveOrUpdate").val();
	 if(saveOrUpdate=="save"){
			var id=$(".idFlag:checked").length;
			var cPrdName;
			var cPrdId;
			var cUnitName;
			if(id==0){
				alertWarning($selectProduct_worning);
				return ;
			}
			$(".idFlag:checked").each(function(){
					tr=$(this).parent().parent();
					cPrdId=$(this).val();
					cPrdName=$(tr).find("td:[name='cPrdName']").html();
					cUnitName=$(tr).find("td:[name='cUnitName']").html();
					selectProduct.push(cPrdId+"_"+cPrdName+"_"+cUnitName+"_");
					excludeId.push(cPrdId);
			});
			$("#addProduct").window('close');
			var oldSize=$("#oldSize").val();
			var newSize=selectProduct.length;
			if(oldSize!=newSize){
				$("#oldSize").val(newSize);
			}
			showSelectProduct();
	 }else{
		 //修改
		 var id=$(".idFlag:checked").length;
			var cPrdName;
			var cPrdId;
			var cUnitName;
			if(id==0){
				alertWarning($selectProduct_worning);
				return ;
			}
			$(".idFlag:checked").each(function(){
					tr=$(this).parent().parent();
					cPrdId=$(this).val();
					cPrdName=$(tr).find("td:[name='cPrdName']").html();
					cUnitName=$(tr).find("td:[name='cUnitName']").html();
					addForUpdate.push(cPrdId+"_"+cPrdName+"_"+cUnitName+"_");
				 	excludeForUpdate.push(cPrdId);
					//excludeId.push(cPrdId);
			});
			$("#addProduct").window('close');
			//显示修改商品新增的方法
			showAddForUpdate();
		 
	 }
  }
  //显示新增为修改的商品方法
  function showAddForUpdate(){
	  	var index=productForUdate.length;
		var agmPrd="";
		for(var i=oldSize;i<addForUpdate.length;i++){
			var data=addForUpdate[i].split("_");
			agmPrd+='<tr><td>'+(i+1+index)+'</td>';
			agmPrd+='<td>'+data[0]+'</td>';
			agmPrd+='<td>'+data[1]+'</td>';
			agmPrd+='<td>'+data[2]+'</td>';
			agmPrd+='<td><input type="text" class="iput_t" name="agmPrice"       price="'+addForUpdate[i]+'"     onblur="updatePriceForAdd(this);" value="'+data[3]+'" ></td>';
			agmPrd+='<td><input type="button"  arr="'+addForUpdate[i]+'"  onclick="UpdataForAdd(this);" class="btn_l" value="删除"></td></tr>';
		}
		$("#updateAgmData").append(agmPrd); 
  }
  //用于判断是否为价格类型的数据
  function updatePriceForAdd(obj){
	  var price=$(obj).val();
	  var priceObj=$(obj).attr("price");
	  if(!checkIsNull(price)){
		  if(!checkIsDouble(price)){
			  	$(obj).val("");
			    $(obj).focus();//获得焦点
				alertWarning("亲,请输入正确的价格!"); 
				return;
		  }else{
			   //保存正确的价格
			   var arr=priceObj.split("_");
			   if(arr[3]!=price){//记录一样
				   addForUpdate.remove(priceObj);
				   price=arr[0]+"_"+arr[1]+"_"+arr[2]+"_"+price;
				   $(obj).attr("price",price);
				   addForUpdate.push(price);
				   $(obj).parent().next().children().first().attr("arr",price);//删除
			   }
		  }
	  }
  }
  //移除新建的记录
  function UpdataForAdd(obj){
	  var dd=$(obj).attr("arr");
	  var info=dd.split("_");
	  if(checkIsDouble(info[3])){
		  //移除要新增的价格信息
		  idAndPriceAddForUpdate.remove(info[0]+"_"+info[3]);
	  }
	  //移除上次记录
	  excludeForUpdate.remove(info[0]);
	  $(obj).parent().remove();
	  addForUpdate.remove(dd);
	  //显示原始的数据
	  showUpdateProduct();
	  //显示新增的虚拟数据,重新遍历新增在界面的新数据
	  oldSize=0;
	  showAddForUpdate();
  }
  //显示选中的商品
  function showSelectProduct(){
			$("#tbody").html("");
			document.getElementById("selectProduct").style.display="";
			var data;
			var html="";
			for(var i=0;i<selectProduct.length;i++){
				data=selectProduct[i].split("_");
				html+='<tr><td>'+(parseInt(1)+i)+'</td>';
				html+='<td>'+data[0]+'</td>';
				html+='<td>'+data[1]+'</td>';
				html+='<td>'+data[2]+'</td>';
				html+='<td><input type="text" class="iput_t" name="agmPrice" id="'+data[0]+'"  pkPrdId='+data[0]+'    price=""    onblur="setValueForId(this);" value="'+data[3]+'"></td>';
				html+=' <td><input type="button"  arr="'+selectProduct[i]+'" attrId="'+data[0]+'"  onclick="removeVal(this);"  class="btn_l"  value="删除"></td></tr>';
			}
			$("#tbody").html(html);

  }
  /**从数组移除该对象*/
  function removeVal(obj){
	  var  id=$(obj).attr("attrId");;
	  var val=$("#"+id).val();
	 var keyValue=$(obj).attr("arr");
	 var pkPrdId=keyValue.split("_")[0];
	  selectProduct.remove(keyValue);
	   excludeId.remove(pkPrdId);
	  showSelectProduct();
	  //还需移除商品填写的价格
	 /*  alert("dd"+pkPrdId);
	  var  obj=$("#"+pkPrdId);
	  alert("obj"+obj);
	 
	  var val=$("#"+id).val();
	  alert("val"+val); */
	/*   var a=document.getElementById("#"+pkPrdId).value;
	  alert("a"+a); */
	  /* var prev=$(obj).parent().prev().children().first();
	  var val=$(prev).val(); */
	  if(checkIsNull(val)){
		  price.remove(pkPrdId);
	  }else{
		  pkPrdId=pkPrdId+"_"+val;
		  price.remove(pkPrdId);
	  } 
  }
//validate The Form
  function checkTheForm(id){
	  var length=$("#"+id).children().length;
	  var sTime="";
	  var eTime="";
	  if(id=="tbody"){
		 sTime="startTime";
		 eTime="endTime";
		 var fkPicFile=$("#fkPicFile").val();
		 if(checkIsNull(fkPicFile)){
			 alertWarning("请添加协议附件");
			 return false;
		 }
	  }else{
		  sTime="updateStartTime";
		  eTime="updateEndTime";
	  }
	  
	  if(length==0){
		  alertWarning("请选择商品");
		  return false;
	  } 
	  var startTime=$("#"+sTime).val();
	  var endTime=$("#"+eTime).val();
	 if(checkIsNull(startTime)==true||checkIsNull(endTime)==true){
		 alertWarning("协议的开始时间和结束时间不允许为空!");
		 return false;
	 }
	 //验证价格
	  var prices=$("input:[name='agmPrice']");
	  var flag=true;
	  for(var i=0;i<prices.length;i++){
		  var value=$(prices[i]).val();
		  if(checkIsNull(value)){
			  flag=false;
			  alertWarning("价格不允许为空");
			  break;
		  }
		  if(!checkIsDouble(value)){
			  flag=false;
			  alertWarning("价格不允许为空");
			  break;
		  } 
	  }
	  return flag;
  }
  //保存供应商的协议信息
  function saveAgreement(){
	  var flag=checkTheForm('tbody');
	  if(flag==false){
		  return;
	  }else{
		  //前置成功
		  $.ajaxFileUpload({
				url:'${basePath}scmInvocing/supplier/uploadImage.shtml',
				secureuri:false,                       //是否启用安全提交,默认为false 
				fileElementId:'ui-upload-input',//文件选择框的id属性
				dataType:'text',                       //服务器返回的格式,可以是json或xml等
				success:function(data){        //服务器响应成功时的处理函数
					//上传成功
					$("#fkPicFile").val(data);		
					 $("#idAndPrice").val(price.join());
					  $.ajax({
							  url:"${basePath}scmInvocing/supplier/saveSupAgm.shtml",
							  dataType:"text",
							  type:"post",
							  data: $("#saveAgmForm").serialize(),
							  error : function(XMLHttpRequest) {
			      	 				ajaxError(XMLHttpRequest);
			      	 			},
							  success:function(result){
								  $("#addAgreement").window('close');
								  $("#addForPkSupId").val(result);
								  $("#isFirst").val(result);
								  //获取协议信息
								  $("#pkSupId").val(result);
								  $("#supId").val(result);
								  selectProduct=[];
								  excludeId=[];
								  price=[];
									$("#tbody").html("");
								  //重新获取shuju 
								  setSupAgmInfo();
							  }
					  });
				},
				error:function(data, status, e){ //服务器响应失败时的处理函数
					alertErrro('上传失败，请重试！');
					return ;
				}
			});
	  }
  }
  //设置供应商的协议信息
  function setSupAgmInfo(){
	  var pkSupId=$("#pkSupId").val();
	  if(checkIsNull(pkSupId)){
		  return;
	  }else{
		  document.getElementById("showSupAgm").style.display="";
		  initSupAgm();
	  }
  }
//初始化参数
  function initSupAgm() {
  	var myform = $("#supAgmInfo");
  	var pagebean = new PageBean(myform);
  	pagebean.setTableId("showSupAgm");
  	pagebean.setFootId("footForSupAgm");
  	pagebean.setCallback(showSupAgm);
  	setPagebeanObj(pagebean); //全局化pageBean对象
  	pagebean.doPage();  //执行分页
  }
  //展示数据
  function showSupAgm(result){
	trimJsonArray(result);
  	$(result).each(function(index,item){
  			var html="<tr>";
			html+='<td class="lv"><a href="#" onclick="updateAgm(this);" pkSupagmId='+item.pkSupagmId+'>'+(index+1)+'</a></td>';
  			html+='<td>'+item.startTime+'</td>';
  			html+='<td>'+item.endTime+'</td>';
  			if(item.comments.length>8){
  	  			html+='<td title="'+item.comments+'">'+item.comments.substring(0,8)+'</td>';
  			}else{
  	  			html+='<td>'+item.comments+'</td>';
  			}
  			html+='<td><input type="button" class=" btn_l ml10" value="删除"  pkSupagmId='+item.pkSupagmId+'  onclick="deleteSupAgm(this);"></td></tr>';
  			$("#showSupAgm").find("tr:eq("+index+")").after(html);
  	});
  }
  /**
   * 修改协议的内容
   */
  function updateAgm(obj){
  	//清空上一次的记录
  	productForUdate=[];
  	excludeForUpdate=[];
  	var fkSupagmId=$(obj).attr("pkSupagmId");
  	  $.ajax({
  	   		url:"${basePath}scmInvocing/supplier/getAgmProductInfo.shtml",
  	   		data:{"fkSupagmId":fkSupagmId},
  	   		dataType:"json",
  	   		type:"post",
  	   		error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			},
  	   		success:function(result){
  	   			trimJsonArray(result);
  	   			$(result).each(function(id,item){
  	   				excludeForUpdate.push(item.fkPrdId);
  	   				if(item.unitName==""){
  						productForUdate.push(item.fkPrdId+"_"+item.prdName+"_无_"+item.agmPrice);
  	   				}else{
  						productForUdate.push(item.fkPrdId+"_"+item.prdName+"_"+item.unitName+"_"+item.agmPrice);
  	   				}
  				 });
  	   			//显示协议的时间信息
  	   			var first=result[0];
  	   			$("#updateStartTime").val(first.agmFromPage);
  	   			$("#updateEndTime").val(first.agmToPage);
  	   			$("#updateComments").val(first.comments);
  	   			$("#fileName").html(first.agmFileName);
	   			$("#fileName").attr("pkAgmFile",first.fkAgmFile);
  	   			$("#supAgmId").val(fkSupagmId);
  				showUpdateProduct();
  	   			$("#updateAgreement").window('open');
  	   		}
  	   	}); 
  }
//修改协议中商品信息
	function  updateAgreementData(){
		 var flag=checkTheForm('updateAgmData');
		  if(flag==false){
			  return;
		  }else{
			  	var  pkSupagmId=$("#supAgmId").val();
				var startTime=$("#updateStartTime").val();
				var endTime=$("#updateEndTime").val();
				var  comments=$("#updateComments").val();
				$.messager.confirm('温馨提示', '你确定要修改协议的内容吗?', function(isOk) {
					if(isOk){
						$.ajax({
							url:"${basePath}scmInvocing/supplier/updateAgmPrdouct.shtml",
							data:{"pkSupagmId":pkSupagmId,"addInfo":addForUpdate.join(),"updateInfo":productForUdate.join(),"startTime":startTime,"endTime":endTime,"comments":comments},
							dataType:"json",
							type:"post",
					 		async:false,
					 		error : function(XMLHttpRequest) {
					 			ajaxError(XMLHttpRequest);
					 		},
					 		success:function(result){
					 		     if(result=="1"){
					 				$("#updateAgreement").window('close');
					 				addForUpdate=[];
					 				//重新获取协议的最新列表信息
					 				initSupAgm();
					 				alertInfo("修改成功!");
					 		     }
					 		}
						});
					}
				});
		  }
	}
  
  
  //下载协议附件
  function downLoad(){
	  	var  fileName=$("#fileName").html();
	  	var form = document.createElement("form");
		document.body.appendChild(form);
		var i = document.createElement("input");
		i.type = "hidden";
		form.appendChild(i);
		i.value =fileName;
		i.name = "attFile";
		var key=document.createElement("input");
		key.type="hidden";
		key.name="key";
		key.value=fileKey;
		form.appendChild(key);
	    form.method="post";
		form.action = "${basePath}common/downloadAttFile.shtml";
		form.submit();
  }
//显示修改协议的商品信息
  function showUpdateProduct(){
  	$("#updateAgmData").html("");
  	var agmPrd="";
  	for(var i=0;i<productForUdate.length;i++){
  		var data=productForUdate[i].split("_");
  		agmPrd+='<tr><td>'+(i+1)+'</td>';
  		agmPrd+='<td>'+data[0]+'</td>';
  		agmPrd+='<td>'+data[1]+'</td>';
  		agmPrd+='<td>'+data[2]+'</td>';
  		agmPrd+='<td><input type="text" class="iput_t"   name="agmPrice"   price="'+productForUdate[i]+'"    onblur="updatePrice(this);" value="'+data[3]+'" /></td>';
  		agmPrd+=' <td><input type="button"  arr="'+productForUdate[i]+'"  arrId="'+data[0]+'"  fkPrdId="'+data[0]+'"  onclick="removeForUpdata(this);" class="btn_l" value="删除"></td></tr>';
  		
  	}
  	$("#updateAgmData").html(agmPrd);
  }
//修改协议中商品的价格信息
  function updatePrice(obj){
  	 var price=$(obj).val();
  	 var priceObj=$(obj).attr("price");
  	 if(!checkIsNull(price)){
  		  if(!checkIsDouble(price)){
  			  	$(obj).val("");
  			    $(obj).focus();//获得焦点``````````
  				alertWarning("亲,请输入正确的价格!"); 
  				return;
  		  }else{
  			   //保存正确的价格
  			   var arr=priceObj.split("_");
  			   if(arr[3]!=price){//记录一样
  				   productForUdate.remove(priceObj);
  				   price=arr[0]+"_"+arr[1]+"_"+arr[2]+"_"+price;
  				   $(obj).attr("price",price);
  				   productForUdate.push(price);
  				   $(obj).parent().next().children().first().attr("id",price);//供删除
  			   }
  		  }
  	  }
  }
//移除协议中原有的商品信息。
  function removeForUpdata(thisObj){
  	var fkSupagmId=$("#supAgmId").val();
  	var fkPrdId=$(thisObj).attr("fkPrdId");
  	  $.ajax({
  		  url:"${basePath}scmInvocing/supplier/isDelete.shtml",
  		  dataType:"text",
  		  type:"post",
  		  data: {"fkAgmId":fkSupagmId,"fkPrdId":fkPrdId},
  		  error : function(XMLHttpRequest) {
   				ajaxError(XMLHttpRequest);
   		  },
  		  success:function(result){
  			 	var message;
  			    if(result!="1"){
  					  		if(result=="0"){
  						 		message="你确定要删除该项记录吗?";
  						 	}else{
  						 		message="该商品可能在使用中,你确定要删除吗?";
  						 	}
  					    	$.messager.confirm('温馨提示',message, function(isOk) {
  					    		if(isOk){
  					    			  var id=$(thisObj).attr("arr");
  					  			  	  $.ajax({
  					  				  url:"${basePath}scmInvocing/supplier/deleteSupPrd.shtml",
  					  				  dataType:"text",
  					  				  type:"post",
  					  				  data: {"fkSupagmId":fkSupagmId,"fkPrdId":fkPrdId},
  					  				  error : function(XMLHttpRequest) {
  					      	 				ajaxError(XMLHttpRequest);
  					      	 		  },
  					  				  success:function(result){
  					  					 	if(result=="1"){
  					  					 			alertInfo("删除成功!");
  					  					 			productForUdate.remove(id);
  					  					 			//显示协议中原有的商品记录
  					  					 			excludeForUpdate.remove(fkPrdId);
  					  					 			showUpdateProduct();
  					  					 		   //显示页面未保存的商品记录
  					  					 		   oldSize=0;
  					  					 		   showAddForUpdate();
  					  					 	}
  					  				  }
  					      	 		
  					  		  });
  					    	 }
  					    	}); 
  			    	}else{
  			 			alertInfo("该项记录不允许删除!");
  			 			return;
  			 	   }
  		 	 }
   		 });
  }
//删除供应商的协议信息
  function deleteSupAgm(obj){
  	  var pkSupagmId=$(obj).attr("pkSupagmId");
  	  $.ajax({
  		  url:"${basePath}scmInvocing/supplier/isDelete.shtml",
  		  dataType:"text",
  		  type:"post",
  		  data: {"fkAgmId":pkSupagmId,"fkPrdId":""},
  		  error : function(XMLHttpRequest) {
   				ajaxError(XMLHttpRequest);
   		  },
  		  success:function(result){
  			  var message;
  			    if(result!="1"){
  			    	if(result=="0"){
  				 		message="你确定执行删除协议操作吗?";
  				 	}else{
  				 		message="该协议正在使用中,你确定要删除吗?";
  				 	}
  			    	$.messager.confirm('温馨提示',message, function(isOk) {
  			    		if(isOk){
  			    			  $.ajax({
  			    				  url:"${basePath}scmInvocing/supplier/deleteSupAgm.shtml",
  			    				  dataType:"text",
  			    				  type:"post",
  			    				  data: {"pkSupagmId":pkSupagmId},
  			    				  error : function(XMLHttpRequest) {
  			        	 				ajaxError(XMLHttpRequest);
  			        	 		  },
  			    				  success:function(result){
  			    					 	if(result=="success"){
  			    					 			alertInfo("删除成功!");
  			    					 			initSupAgm();
  			    					 	}
  			    				  }
  			    		  });
  			    		}
  			    	});
  			    }else{
  			 		alertInfo("该协议不允许删除!");
  			 		return;
  			 	}
  		  }
    });
  }
  //checkis Fax
  function checkIsFax(thisObj){
	  var fax=$(thisObj).val();
	  if(!checkIsNull(fax)){
		  var regexp=/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/;
		   if(!regexp.test(fax)){
			   alertWarning("请输入正确的传真号码");
			   $(thisObj).val("");
		   }
	  }
  }
  //检查联系方式是否填正确
  function checkIsTrue(thisObj){
	  var value=$(thisObj).val();
	  if(!checkIsNull(value)){
		   var prefix=value.substring(0,1);
		   //验证手机号码
		   if(prefix=="1"){
			   var reg=/1[3,4,5,8][0-9]{9}$/;
			   if(!reg.test(value)){
				   alertWarning("请输入正确的联系方式");
				   $(thisObj).val("");
			   }
		   //验证为固定电话，传真		   
		   }else if(prefix=="0"){
			   var regexp=/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/;
			   if(!regexp.test(value)){
				   alertWarning("请输入正确的联系方式");
				   $(thisObj).val("");
			   }
		   }else{
			   alertWarning("请输入正确的联系方式");
			   $(thisObj).val("");
		   }
	  }
  }
  //设置到Id中
  function setValueForId(obj){
	  var val=$(obj).val();
	  var pkPrdId=$(obj).attr("pkPrdId");
	 if(!checkIsNull(val)){
		 if(!checkIsDouble(val)){
			 alertWarning("必须为数字类型!");
			 $(obj).val("");
			 return;
		 }else{
			//移除原有的数据记录
				var lastObj=$(obj).parent().next().children().first();
				var newId=lastObj.attr("arr");
				var newData=newId.split("_");
				newData[3]=val;
				var pp=$(obj).attr("price");
				price.remove(pkPrdId+"_"+pp);
				selectProduct.remove(newId);
				newId=newData[0]+"_"+newData[1]+"_"+newData[2]+"_"+newData[3];
				lastObj.attr("arr",newId);
				selectProduct.push(newId);
				price.push(pkPrdId+"_"+val);
				$(obj).attr("price",val);
		 } 
	 }
  }
  /**取消选择*/
  function canCelSel(){
	  selectProduct=[];
	  excludeId=[];
	  price=[];
		$("#tbody").html("");
	  $('#addAgreement').window('close');	  
  }
	//设置全选按钮全选
	function setSelectAll(className,thisobj){
		if($(thisobj).attr("checked")=="checked"){
				$("."+className).attr("checked",true);
		}else{
			$("."+className).attr("checked",false);
		}
	}
	//勾选单选按钮时是否全选
	function isSelected(selectName,selectAllId,tableId){
		var length=$("input:[name='"+selectName+"']:checked").length;
		var pageSize=$("#"+tableId).find("tr").length-1;
		if(pageSize==length){//全选
			$("#"+selectAllId).attr("checked",true);
		}else{
			$("#"+selectAllId).attr("checked",false);
		} 
	}
	//重新上传协议
	 function  reUpload(){
		  $.ajaxFileUpload({
				url:'${basePath}scmInvocing/supplier/uploadImage.shtml',
				secureuri:false,                       //是否启用安全提交,默认为false 
				fileElementId:'ui-upload-update',//文件选择框的id属性
				dataType:'text',                       //服务器返回的格式,可以是json或xml等
				success:function(data){        //服务器响应成功时的处理函数
					//修改协议的附件
					var pkAgmFile=$("#fileName").attr("pkAgmFile");
					$.ajax({
						url:"${basePath}scmInvocing/supplier/updateAgmFile.shtml",
						data:{"fileName":data,"pkAgmFile":pkAgmFile},
						dataType:"text",
						type:"post",
				 		async:false,
				 		error : function(XMLHttpRequest, status, e) {
				 			ajaxError(XMLHttpRequest);
				 			
				 		},
				 		success:function(result){
				 		     if(result!=""){
				 		    	 $("#fileName").html(result);
				 				 alertInfo("上传成功!");
				 		     }
				 		}
					});
				},
				error:function(data, status, e){ //服务器响应失败时的处理函数
					alertErrro('上传失败，请重试！');
					return ;
				}
			});
	 }
//移除数组中元素的方法
Array.prototype.remove = function(s) {
	for (var i = 0; i < this.length; i++) {
		if (s == this[i]) {
			this.splice(i, 1);
		}
	}
};
</script>
</head>
<body class="bg">

<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
    		<shiro:hasPermission name="scmInvocing/productInfo/forwardToProductInfo.shtml">
    				  <li ><a href="${basePath}scmInvocing/productInfo/forwardToProductInfo.shtml"><i class="nav_icon_b"></i><br>商品信息</a></li>
    		</shiro:hasPermission>
    		 <shiro:hasPermission name="scmInvocing/countUnit/forwardToUnitInfo.shtml">
    		 		<li><a href="${basePath}scmInvocing/countUnit/forwardToUnitInfo.shtml"><i class="nav_icon_b"></i><br>单位设置</a></li>
    		 </shiro:hasPermission>
    		 <shiro:hasPermission name="scmInvocing/supplier/forwardToSupply.shtml">
    		 		   <li  class="content_hover"><a href="${basePath}scmInvocing/supplier/forwardToSupply.shtml"><i class="nav_icon_a"></i><br>供应商信息</a></li>
    		 </shiro:hasPermission>
    		  <shiro:hasPermission name="scmInvocing/priceManager/forwardToList.shtml">
    		 		  <li><a href="${basePath}scmInvocing/priceManager/forwardToList.shtml"><i class="nav_icon_f"></i><br>价格管理</a></li>
    		 </shiro:hasPermission>
    		   <shiro:hasPermission name="scmInvocing/scmPurOrder/findInvoPurOrder.shtml">
            	  <li><a href="${basePath}scmInvocing/scmPurOrder/findInvoPurOrder.shtml"><i class="nav_icon_b"></i><br>采购订单</a></li>
    		 </shiro:hasPermission>
    		   <shiro:hasPermission name="scmInvocing/scmPayForm/findInvoOrderPay.shtml">
           		   <li><a href="${basePath}scmInvocing/scmPayForm/findInvoOrderPay.shtml"><i class="nav_icon_b"></i><br>付款申请</a></li>
    		 </shiro:hasPermission>
   	</ul>
    </div>
    <div class="content_r mt10">
    	<form action="${basePath}scmInvocing/supplier/saveSupply.shtml" id="saveSupply" method="post" >
    	<input type="hidden" name="modiBy" value="${map.userId}"/>
    	<input type="hidden" name="fkBranId" value="${map.branId}"/>
    	<input type="hidden" name="orderTime" value="${map.nowDate}"/>
    	<input type="hidden" name="pkSupId"  id="addForPkSupId" value="">
    	<input type="hidden" name="isOk"  id="isOk" value=""/>
    	<div class="file_single_dl_y f14 fixed">
       		<dl class="fixed" style="overflow:hidden">
            	<dd><h1><label>供应商信息录入</label></h1></dd>
            </dl>
            <hr>
        	<dl class="fixed" style="overflow:hidden">
            	<dd><label>制单人:</label>${map.userName}</dd>
                <dd><label>制单日期：</label>${map.nowDate}</dd>
                <dd><label>制单单位：</label>${map.branName } </dd>
            </dl>
             <hr>
            <dl class="fixed" style="overflow:hidden">
                <dd><label>供应商名称：</label><input type="text" class="iput_t w200"  name="supName" id="supName"><font style="color:#F00">*</font></dd>
                <dd><label>供应商行业：</label><input type="text" class="iput_t w200"  name="supInd" id="supInd"></dd>
           		<dd><label>供货地址：</label><input type="text" class="iput_t w200"  name="deliverAddr" id="deliverAddr"><font style="color:#F00">*</font></dd>
           		
            </dl>
            
            <dl class="fixed" style="overflow:hidden">
            	<dd><label>法人代表：</label><input type="text" class="iput_t w200" name="legalRep"  id="legalRep"></dd>
                <dd><label>机构代码：</label><input type="text" class="iput_t w200" name="orgCode"  id="orgCode"></dd>
            	<dd><label>开户银行：</label><input type="text" class="iput_t w200"  name="bank"	id="bank"></dd>
            	
            </dl>
            <dl class="fixed" style="overflow:hidden">
                <dd><label>银行账号：</label><input type="text" class="iput_t w200"  name="bankAccount" id="bankAccount"></dd>
                <dd><label>联系人：</label><input type="text" class="iput_t w200"  name="conName" id="conName"><font style="color:#F00">*</font></dd>
            	<dd><label>联系方式：</label><input type="text" class="iput_t w200"  name="conMobile" id="conMobile"  title="若填写的为固话，请遵循区号-固话号码的规则，例如021-7930233,或加分机号021-7930181-0001"   onblur="checkIsTrue(this);"><font style="color:#F00">*</font></dd>
            </dl>
            <dl class="fixed" style="overflow:hidden">
            	<dd><label>通讯地址：</label><input type="text" class="iput_t w200"  name="conAddr" id="conAddr"><font style="color:#F00">*</font></dd>
                <dd><label>传  真：</label><input type="text" class="iput_t w200"  title="传真号码格式必须为:区号-固定号码,例如:021-7930181,或加分机号021-7930181-0001"    name="conFax" id="conFax"  onblur="checkIsFax(this);"></dd>
				<dd><label>Email：</label><input type="text" class="iput_t w200"  name="conEmail" id="conEmail"></dd> 
            </dl>
            <dl class="fixed" >
            	<dd><label>备注信息：</label><textarea  rows="5" cols="80" class="textare w200"  name="comments" id="comments"></textarea></dd> 
            </dl>
        </div>
        </form>
        <!-- 与供应商签订的协议列表 -->
         <div>
          	<ul class="fixed" id="tab_conbox_a">
                <li class="m10">
               		<form id="supAgmInfo" action="${basePath}scmInvocing/supplier/getSupAgmInfo.shtml">
                	  <input type="hidden" name="pkSupId" id="pkSupId" value=""/>
                	  <input type="hidden" name="fkSupId"  id="supId" value=""/>
                	  <input type="hidden" name="pageNo" value="1"/>
    			      <input type="hidden" name="pageSize" value="8"/>
                	<table class="table"  id="showSupAgm"  style="display: none">
                    	<tr>
                        	<th>序号</th>
                            <th>协议开始</th>
                            <th>协议结束</th>
                            <th>备注</th>
                            <th width="200">操作</th>
                        </tr>
                      
                    </table>
                    </form>
                     <div class="page fr m10" id="footForSupAgm">
                           
                      </div>
                    <!----底部按钮----->
                    <div class="btm_btn mt10">
                            <dl>
                            		<dd ><input class="btn" type="button" onclick="addAgrement();" value="添加协议"></dd>
                                	<dd ><input class="btn" type="button" onclick="saveSupply();" value="保存"></dd>
                                  	<dd ><input class="btn" type="button" onClick="saveSupplyAgain();" value="保存并继续"></dd>
                                    <dd ><input class="btn" type="button" onClick="forwardToSupplyList();" value="返回"></dd>  
                            </dl>
                    </div>
                </li>
                </ul>
          </div>
    </div>
</div>

<!-- 一下是弹出框 -->

<!---弹出层 成员信息编w辑--->
<div id="addProduct" class="easyui-window" title="供应商商品目录" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:1175px; height:470px;position:relative;">
    	<div class="file_single_dl f14 fixed p10">
    		<form action="${basePath}scmInvocing/productInfo/findProductList.shtml" id="productInfo">
    		<input type="hidden" name="pageNo"  id="pageNo"    value="1"/>
    		<input type="hidden" name="pageSize" id="pageSize" value="8"/>
    		<input type="hidden" name="prdStatus" value="1"/>
    		<input type="hidden" name="fkPrdcateId" id="fkPrdcateId" value="001006"/>
    		<input type="hidden" name="excludeId" id="excludeId" value=""/>
    		<input type="hidden"  id="saveOrUpdate" value=""/>
        	<dl class="fixed fl">
            	<dd><label>商品编号：</label><input type="text" class="iput_t " name="pkPrdId"	 id="pkPrdId"></dd>
                <dd><label>商品名称：</label><input type="text" class="iput_t " name="prdName"  id="prdName"></dd> 
            </dl>
            </form>
            <input type="button" class="btn fl ml10" value="查询" onclick="findProductInfo();">
        </div>
        <div class="tab_normal">
            <ul class=" fixed" id="tab_a"></ul>
            <div class="payment_l tc" style="height:410px !important">
               <div style="overflow-y: auto;overflow-x: auto;width: 158px; height: 360px;"  class="ztree" id="sptree"></div>
            </div>
            <div style=" width:850px;" class="m10 fl">
                <table class="table" id="showData">
                                <tr> 
                                    <th><input type="checkbox"   onclick="setSelectAll('idFlag',this);"  id="selectAll" /></th>
                                    <th>序号</th>
                                    <th>商品编号</th>
                                    <th>商品名称</th>
                                    <th>商品分类</th>
                                    <th>规格</th>
                                    <th>计量单位</th>
                                    <th>备注</th>
                                    <th>状态</th>
                                </tr>
                               
                            </table>
                <input class="btn mt10" type="button" value="确定" onclick="getSelectProduct();">
                <input type="button" value="取消" onclick="$('#addProduct').window('close')" class="btn mt10">
                <!----翻页----->
                        <div class="page fr m10" id="foot">
                           
                        </div>
                <!----翻页----->
			</div>
		</div>
</div>
<!---为供应商协议--->
<div id="addAgreement" class="easyui-window" title="新增供应商商品" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:870px; height:500px;position:relative;">
	<div class="file_si m10">
		<form id="saveAgmForm">
		<input type="hidden" id="oldSize" value="0"/>
		<input type="hidden" id="idAndPrice" name="idAndPrice"/>
		<input type="hidden" id="isFirst" name="isFirst" value=""/>
    	<dl>
        	<dd>
				<label>协议有效期：</label>
                <a onclick="WdatePicker({el:'d12'})" href="#" class="customer_calendar_icon"></a>
                <input type="text" onclick="WdatePicker()" id="startTime" name="startTime" class="Wdate iput_t w82">
                <span>至</span>
                <a onclick="WdatePicker({el:'d13'})" href="#" class="customer_calendar_icon"></a>
                <input type="text" onclick="WdatePicker()" id="endTime" name="endTime"  class="Wdate iput_t w82"><font style="color:#F00">*</font>
            </dd>
             <dd><label>上传协议：</label>
                    	<div class="upload_box" style=" width:385px !important">	
                        <input type="text" id="fkPicFile"  value=""  name="fkAgmFile"  class="iput_t fl">
                        <span id="ui-upload-holder fr">
                            <input type="button" class="btn" value="浏览" id="ui-upload-txt">
                            <input type="file" id="ui-upload-input" name="file" style="width:255px !important; left:130px !important" onchange="fkPicFile.value = this.value;">
                        </span>
                    </div>
            </dd>
        </dl>
        <div class="clear"></div>
        <label>备注：</label><textarea class="textare w200" id="comments" name="comments"></textarea>
        </form>
         <div id="scrollTable">
            <table class="table">
                <col width="80px"></col>
                <col width="160px"></col>
                <col width="200px"></col>
                <col width="80px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody>
                    <tr>
                        <th>序号</th>
                        <th>商品编号</th>
                        <th>商品名称</th>
                        <th>计量单位</th>
                        <th>商品单价</th>
                        <th>操作</th>
                    </tr>
                </tbody>
            </table>
			<div>
            <table class="table" id="selectProduct" >
				<col width="80px"></col>
                <col width="160px"></col>
                <col width="200px"></col>
                <col width="80px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody id="tbody">
                       
                </tbody>
            </table>
            </div>
        </div>
    </div>
    <div class="btm_btn btm_bg">
    	<dl>
        	<dd><input type="button" class="btn" onclick="forwardToSelectProduct('save');" value="新增"></dd>
        	<dd><input type="button" class="btn" onclick="saveAgreement();" value="保存"></dd>
            <dd><input type="button" class="btn" onclick="canCelSel();" value="取消"></dd>
        </dl>
    </div>
</div>
<!--修改供应商协议中商品的信息 -->
<div id="updateAgreement" class="easyui-window" title="修改供应商商品" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:870px; height:500px;position:relative;">
	<div class="file_si m10">
		<form id="updateAgmForm">
		<input type="hidden" id="oldSize" value="0"/>
		<input type="hidden" id="idAndPrice" name="idAndPrice"/>
		<input type="hidden" id="SupIdForm" name="fkSupId" />
		<input type="hidden" id="supAgmId" name="fkSupagmId" />
		<input type="hidden" id="updateisFirst" name="isFirst"  value="${entity.pkSupId}"/>
    	<dl>
        	<dd>
				<label>协议有效期：</label>
                <a onclick="WdatePicker({el:'d12'})" href="#" class="customer_calendar_icon"></a>
                <input type="text" onclick="WdatePicker()" id="updateStartTime" name="startTime" class="Wdate iput_t w82">
                <span>至</span>
                <a onclick="WdatePicker({el:'d13'})" href="#" class="customer_calendar_icon"></a>
                <input type="text" onclick="WdatePicker()" id="updateEndTime" name="endTime"  class="Wdate iput_t w82"><font style="color:#F00">*</font>
            </dd>
            <dd class="lv"><label>文件名称：</label><a href="#"  onclick="downLoad();"><font id="fileName" ></font></a></dd>
            <dd><label>备注：</label><textarea class="textare w200"   id="updateComments" name="comments"></textarea></dd>
            <dd><label>上传协议：</label>
                    <div class="upload_box fl" style=" width:260px !important">	
                        <input type="text" id="fkPicFile"  value=""  name="fkAgmFile"  class="iput_t fl w200">
                        <span id="ui-upload-holder fr">
                            <input type="button" class="btn_l ml10" value="浏览" id="ui-upload-txt">
                            <input type="file" id="ui-upload-update"   class="ui-upload-input" name="file" style="width:260px !important;" onchange="fkPicFile.value = this.value;">
                        </span>
                    </div>
                    <input type="button" class="btn_l ml10 fl"  onclick="reUpload();" value="上传">
            </dd>
        </dl>
         </form>
        <div class="clear"></div>
         <div id="scrollTable">
            <table class="table">
                <col width="80px"></col>
                <col width="160px"></col>
                <col width="200px"></col>
                <col width="80px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody>
                    <tr>
                        <th>序号</th>
                        <th>商品编号</th>
                        <th>商品名称</th>
                        <th>计量单位</th>
                        <th>商品单价</th>
                        <th>操作</th>
                    </tr>
                </tbody>
            </table>
			<div>
            <table class="table" id="selectProduct" >
				<col width="80px"></col>
                <col width="160px"></col>
                <col width="200px"></col>
                <col width="80px"></col>
                <col width="200px"></col>
                <col></col>
                <tbody id="updateAgmData">
                  
                </tbody>
            </table>
            </div>
        </div>
    </div>
    <div class="btm_btn btm_bg">
    	<dl>
        	<dd><input type="button" class="btn" onclick="forwardToSelectProduct('update');" value="新增"></dd>
        	<dd><input type="button" class="btn" onclick="updateAgreementData();" value="修改"></dd>
            <dd><input type="button" class="btn" onclick="canCelSelUpdate();" value="取消"></dd>
        </dl>
    </div>
</div>
</body>
</html>